//
//  ShoucangTableViewCell.m
//  XRSquare
//
//  Created by UaenaMo on 2018/8/15.
//  Copyright © 2018年 UaenaMo. All rights reserved.
//

#import "ShoucangTableViewCell.h"

@interface ShoucangTableViewCell ()
{
    UILabel * titleLabel;
    UILabel * timeLabel;
    UIImageView * imageV;
    UILabel * nameLabel;
    UILabel * typeLabel;
    NSDictionary * contentData;
}
@end

@implementation ShoucangTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, ScreenWidth, 20)];
        titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:titleLabel];
        
        timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 35, ScreenWidth, 15)];
        timeLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:timeLabel];
        
        imageV = [[UIImageView alloc]initWithFrame:CGRectMake(10, 60, 30, 30)];
        imageV.contentMode = UIViewContentModeScaleAspectFill;
        imageV.clipsToBounds = YES;
        [self addSubview:imageV];
        
        nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(50, 60, ScreenWidth, 30)];
        nameLabel.font = [UIFont systemFontOfSize:15];
        [self addSubview:nameLabel];
        
        typeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 20)];
        typeLabel.font = [UIFont systemFontOfSize:12];
        typeLabel.backgroundColor = themeColor;
        typeLabel.layer.cornerRadius = 10;
        typeLabel.clipsToBounds = YES;
        typeLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:typeLabel];
        typeLabel.center = CGPointMake(ScreenWidth - 35, 75);
        
        UIView * line = [[UIView alloc]initWithFrame:CGRectMake(0, 99, ScreenWidth, 1)];
        line.backgroundColor = [UIColor colorFromHexCode:@"f3f3f3"];
        [self addSubview:line];
        
        UIButton * user = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth, 50)];
        [user addTarget:self action:@selector(selectUser) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:user];
        
    }
    return self;
}

+(CGFloat)height
{
    return 100;
}

-(void)loadData:(NSDictionary *)data
{
    titleLabel.text = [data objectForKey:@"TaskTitle"];
    timeLabel.text = [data objectForKey:@"TaskTime"];
    [imageV sd_setImageWithURL:[NSURL URLWithString:[data objectForKey:@"TaskPublisherPic"]]];
    nameLabel.text = [data objectForKey:@"TaskPublisherNickName"];
    typeLabel.text = [data objectForKey:@"Type"];
}


-(void)selectUser
{
    [self.delegate user:[contentData objectForKey:@"TaskPublisherUID"]];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
